<table id="dg" title="数据列表" style="width:550px;height:250px">
</table>

<div id="toolbar">
    <div style="font-size:1.0em">
    <label style="margin-left:10px"> 日期：</label>
    <input id="date" type="text" value="2016-11-02" class="easyui-datebox" data-options="formatter:myformatter,parser:myparser" />
        <script type="text/javascript">
 function myformatter(date){
 var y = date.getFullYear();
 var m = date.getMonth()+1;
 var d = date.getDate();
 return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
}
 function myparser(s){
 if (!s) return new Date();
 var ss = (s.split('-'));
var y = parseInt(ss[0],10);
 var m = parseInt(ss[1],10);
var d = parseInt(ss[2],10);
if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
return new Date(y,m-1,d);
}else{
 return new Date();
 }
 }
 </script>
    <a href="#" style="margin-left:10px;width:60px" class="easyui-linkbutton" onclick="getabout()">查询</a>
        <!--<a href="#" class="easyui-linkbutton" onclick="exportdata()">全部导出</a>-->
    </div>
</div>

<script type="text/javascript">
    $('#dg').datagrid({
        url: '/back/itemfind/query',
        collapsible: true,
        toolbar: '#toolbar',
        rownumbers: true,
        pageSize:20,
        pagination: true,
        pageList: [10, 20,50],
        fit: true,
        columns: [[
            {field: 'id', title: 'ID', width: 80, hidden: true},
             {field: 'Rank', title: 'Rank', width: 80, align: 'center'},
             {field: 'ASIN', title: 'ASIN', width: 80, align: 'center'},
                        {field: 'DetailUrl', title: 'DetailUrl', width: 300,align: 'center',
                formatter: function (value, row, index) {
                    return "<a href='" + value + "' target='_blank'>" + value + "</a>";
                }},
             {field: 'Condition', title: 'Condition', width: 300, align: 'center'},
             {field: 'Star', title: 'Star', width: 80, align: 'center'},
             {field: 'Reviews', title: 'Reviews', width: 80, align: 'center'},
             {field: 'Createtime', title: 'Createtime', width: 80, align: 'center'}



        ]]
    });


    function getabout() {
        var datename = $('#date').datebox('getValue');
        if(datename==""){
                       $.messager.show({	// show error message
                title: '消息',
                msg: "日期不能为空(20161010)"
            });
            return
        }

        $('#dg').datagrid('load', {
            datename: datename,
        });
    }

        function exportdata() {
        var datename = $('#date').datebox('getValue');
        if(datename==""){
           $.messager.show({	// show error message
                title: '消息',
                msg: "请选择日期"
            });
            return
        }

        $.post('/back/itemfind/export', {'datename':datename}, function (result) {
                if(result.status==true){
                    window.open(result.info)
                }else{
                $.messager.show({	// show error message
                title: '消息',
                msg: result.info
            });
                }
           })
    }
</script>
